package com.cy;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class ProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class,args);
    }
    @Value("${server.port}")
    private String server;
    @RestController
    public class ProviderController{
          @GetMapping("/provider/echo/{msg}")
          public String doEcho(@PathVariable String msg) throws InterruptedException {//Echo为回显的含义
              //Thread.sleep(500000);//模拟耗时操作
              //通过如下语句默认服务调用过程中的异常
              if(msg==null||msg.length()<3)
                  throw new IllegalArgumentException("参数不合法");
              return server+" say: hello "+msg;
          }
    }
}
